package com.ktjiaoyu.utils.fastjson2;

import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.filter.PropertyFilter;
import com.alibaba.fastjson2.filter.PropertyPreFilter;

import java.util.Set;

/**
 * @Description
 * @Author 李楚鹏
 * @Date 2024/12/25 上午9:29
 **/

public class FastJson2SensitivePropFilter implements PropertyPreFilter {
    public FastJson2SensitivePropFilter(Set<String> excludes){
        this.excludes=excludes;
    }
    private Set<String> excludes;

    @Override
    public boolean process(JSONWriter jsonWriter, Object obj, String propertyName) {
        if (excludes==null){
            return true;
        }
        boolean isNeed= !excludes.contains(propertyName);
        return isNeed;
    }


}
